/*
 * @Author: 飞越疯人院 353362604@qq.com
 * @Date: 2022-09-13 13:42:20
 * @LastEditors: 飞越疯人院 353362604@qq.com
 * @LastEditTime: 2022-11-18 15:56:44
 * @FilePath: \adminstration\src\Common\Router\MenuNavList\Environmental\EnvironmentData.jsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { API_LIST } from '../../../Api/Api'
import { commonTableList, BuiltInData } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton, OpenTwoRouter } from '../Common/options'

export const Project = async ({ url, OptionsEvent, Permission, actionRef }) => {
    let data = {
        type: '系统设置',
        pageSize: 10000,
        params: { pageIndex: 1 },
        hideInSearch: true,
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            Permission?.findIndex(v => v.uuid === 'e31709ca-cadf-4cae-b566-cfd822eb827b') !== -1 && (
                <AddDataButton OptionsEvent={OptionsEvent} url={url} type="primary" icon="add" title="新增项目" />
            ),
        ],
        columns: [
            commonTableList.uuid,
            { ...commonTableList.code, rules: true },
            { ...commonTableList.tableName, title: '项目名称', ellipsis: true },
            { ...commonTableList.fullName, title: '项目全称', ellipsis: true },
            {
                dataIndex: 'projectTypeUuid',
                title: '项目类型',
                valueType: 'input',
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'projectStatus',
                title: '项目状态',
                valueType: 'select',
                valueEnum: BuiltInData.projectStatus,
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'totalInvestAmount',
                title: '总投资额',
                valueType: 'input',
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'accruingAmount',
                title: '累计投资',
                valueType: 'input',
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'planBitulith',
                title: '沥青计划产量(kg)',
                valueType: 'input',
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'actualBitulith',
                title: '沥青实际产量(kg)',
                valueType: 'input',
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'planCementConcrete',
                title: '水泥计划产量(m³)',
                valueType: 'input',
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'actualCementConcrete',
                title: '水泥实际产量(m³)',
                valueType: 'input',
                rules: true,
                width: 150,
            },
            { ...commonTableList.sortId, rules: true },
            { ...commonTableList.isEnabled, rules: true },
            {
                dataIndex: 'webUrl',
                title: '网址',
                valueType: 'input',
                width: 150,
                ellipsis: true,
            },
            {
                dataIndex: 'apiUrl',
                title: '接口访问地址',
                valueType: 'input',
                width: 150,
                ellipsis: true,
            },
            {
                dataIndex: 'address',
                title: '项目地址',
                valueType: 'input',
                width: 150,
                ellipsis: true,
            },
            commonTableList.remark,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 240,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === '7dcb226b-8984-4b0f-b02e-373231019258') !== -1 && (
                            <ModDataButton
                                OptionsEvent={OptionsEvent}
                                key="modify"
                                title="修改"
                                url={url}
                                data={record}
                            />
                        ),
                        <OpenTwoRouter
                            key="TwoOne"
                            title="固定数据"
                            twoTitle="项目信息固定数据"
                            modal="EditTableModal"
                            OptionsEvent={OptionsEvent}
                            other={{
                                page: 'Project',
                                actionRef,
                                Permission,
                                oneData: record,
                                header: data.columns,
                            }}
                        />,
                        Permission.findIndex(v => v.uuid === '496fd5ec-96c3-483f-832b-9ac8a1783cc3') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="delete"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return data
}
